package com.poorstu.web.auditaction;

import java.text.SimpleDateFormat;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import com.common.base.web.BaseAction;
import com.poorstu.manager.LoadManager;
import com.poorstu.manager.StudentManager;
import com.poorstu.model.HomeMod;
import com.poorstu.model.LoadMod;
import com.poorstu.model.LoginMod;

public class AuditLoadShowAction extends BaseAction {
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
				try{

		int allUserId1 =(Integer)request.getSession().getAttribute("allUserId");			
		int loadId=Integer.parseInt(request.getParameter("loadId"));
		StudentManager stu =(StudentManager)getBean("studentManager");
		//LoadManager loadManager=(LoadManager)getBean("loadManager");
		LoadMod load=stu.selectLoad(loadId);
		request.setAttribute("load", load);
		
		HomeMod homeMod=stu.getHome(allUserId1);
		 request.setAttribute("homeMod", homeMod);
		
		int allUserId=load.getAuditss().getLogins().getId();
		LoginMod login=stu.selectStudentById(allUserId);
		request.setAttribute("login", login);
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		String birthday= sdf.format(login.getStu().getAges());
		request.setAttribute("birthday", birthday);
		
		return mapping.findForward("succ");
				}catch(Exception e){
					e.printStackTrace();
					
				}
		
				return mapping.findForward("failure");
	}
	

}
